

const buttons = {
    Add: false,
    Query: false,
    Refresh: false,
    SwitchToDoc: false,
    ZRCK: false,
    ZRZDJ: false,
    StagingSave: false,
    Save: false,
    Cancel: false,
    MoreOp: false,
    Return: false,
    First: false,
    Pre: false,
    Next: false,
    Last: false,
    AddLine: false,
    DelLine: false,
    InsLine: false,
    CopyLine: false,
    PasteLine: false,
    Edit: false,
    Delete: false,
    BatchEdit: false,
    Print: false,
    Link2: false,
    output: false,
    File: false,
    ListReport: false,
    BatchAddSub: false,
    Sort: false,
    AdjustSort: false,
    BatchDelete: false,
    entryapply: false,
    cardrpt: false,
    ImportData: false,
    YLDZQ: false,
    SendDZQ: false,
    
};

let buttonsVisible = Object.assign({}, buttons);
let buttonsDisabled = Object.assign({}, buttons);
Object.keys(buttonsDisabled).forEach((key) => {
    buttonsDisabled[key] = true;
});

export default function (status) {

    const {button} = this.props;

    // 主表的按钮状态
    if(status === 'init') {
        let changeButtons = ['Add','YLDZQ','SendDZQ', 'Query', 'BatchEdit', 'SwitchToDoc','ZRCK','ZRZDJ', 'BatchDelete', 'AdjustSort', 'Sort', 'Refresh', 'BatchAddSub', 'ListReport', 'Print', 'File', 'output', 'Link2', 'entryapply'];

        Object.keys(buttons).forEach((key) => {
            if(changeButtons.includes(key)) {
                buttonsVisible[key] = true;
            }
            else {
                buttonsVisible[key] = false;
            }
            buttonsDisabled[key] = true;
        });
    }
    // 选择主组织后
    else if(status === 'mainOrg') {
        let changeButtons = ['Add','YLDZQ','SendDZQ', 'Query', 'BatchEdit', 'SwitchToDoc','ZRCK','ZRZDJ', 'BatchDelete', 'AdjustSort', 'Sort', 'Refresh', 'BatchAddSub', 'ListReport', 'Print', 'File', 'output', 'entryapply', 'Link2', 'ImportData'];

        let ableButtons = ['Add', 'YLDZQ','SendDZQ','Query', 'Link2', 'ImportData'];

        Object.keys(buttons).forEach((key) => {
            if(changeButtons.includes(key)) {
                buttonsVisible[key] = true;
                if(ableButtons.includes(key)) {
                    buttonsDisabled[key] = false;
                }
            }
            else {
                buttonsVisible[key] = false;
                buttonsDisabled[key] = true;
            }
        });
    }
    // 主表有数据的按钮状态
    else if(status === 'mainHadData') {
        let changeButtons = ['Add', 'YLDZQ','SendDZQ','Query', 'BatchEdit', 'SwitchToDoc','ZRCK','ZRZDJ', 'BatchDelete', 'AdjustSort', 'Sort', 'Refresh', 'BatchAddSub', 'ListReport', 'Print', 'File', 'output', 'Link2', 'entryapply', 'cardrpt', 'ImportData'];

        Object.keys(buttons).forEach((key) => {
            if(changeButtons.includes(key)) {
                buttonsVisible[key] = true;
                buttonsDisabled[key] = false;
            }
            else {
                buttonsVisible[key] = false;
                buttonsDisabled[key] = true;
            }
        });
    }
    // 进入到新增/修改页面后的按钮状态
    else if(status === 'addEditPage') {
        let changeStatus = ['StagingSave', 'Save', 'Cancel', 'AddLine', 'DelLine'];

        Object.keys(buttons).forEach((key) => {
            if(changeStatus.includes(key)) {
                buttonsVisible[key] = true;
                buttonsDisabled[key] = false;
            }
            else {
                buttonsVisible[key] = false;
                buttonsDisabled[key] = true;
            }
        });
    }
    // 调整顺序页面按钮状态
    else if(status === 'adjustSort') {
        let changeStatus = [ 'Save', 'Cancel'];
        Object.keys(buttons).forEach((key) => {
            if(changeStatus.includes(key)) {
                buttonsVisible[key] = true;
                buttonsDisabled[key] = false;
            }
            else {
                buttonsVisible[key] = false;
            }
        });
    }
    // 进入到新增修改页面的预览态
    else if(status === 'addEditPageBrowse') {
        let changeButtons = ['Edit'];

        Object.keys(buttons).forEach((key) => {
            if(changeButtons.includes(key)) {
                buttonsVisible[key] = true;
                buttonsDisabled[key] = false;
            }
            else {
                buttonsVisible[key] = false;
                buttonsDisabled[key] = true;
            }
        });
    }
    button.setButtonDisabled(buttonsDisabled);
    button.setButtonVisible(buttonsVisible);
}